package com.teamcenter.rac.massupdate.databinding;

import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.massupdate.model.UpdateJobModel;
import com.teamcenter.rac.massupdate.utils.MassUpdateHelper;
import com.teamcenter.rac.massupdate.utils.SourceHelper;
import com.teamcenter.rac.util.AdapterUtil;
import org.eclipse.ui.views.properties.IPropertySource;

public class TargetPartChangeObservable
  extends AbstractModelObservable
{
  public void doSetValue(Object paramObject)
  {
    super.doSetValue(paramObject);
    final Object localObject = paramObject;
    AbstractAIFOperation local1 = new AbstractAIFOperation()
    {
      public void executeOperation()
        throws Exception
      {
        UpdateJobModel localUpdateJobModel = TargetPartChangeObservable.this.getUpdateJobModel();
        boolean bool = false;
        IPropertySource localIPropertySource1 = (IPropertySource)localObject;
        if (localIPropertySource1 != null)
        {
          TCSession localTCSession = (TCSession)getSession();
          TCComponent localTCComponent1 = SourceHelper.getAssociatedComponent(localIPropertySource1, localTCSession);
          if (localTCComponent1 != null) {
            TargetPartChangeObservable.this.fireThumbnailImageRequest(localTCComponent1, "targetPart", "targetPartImageDescriptor");
          }
          TCComponentItemRevision localTCComponentItemRevision1 = (TCComponentItemRevision)AdapterUtil.getAdapter(localTCComponent1, TCComponentItemRevision.class);
          if (localTCComponentItemRevision1 != null)
          {
            IPropertySource localIPropertySource2 = localUpdateJobModel.getChangeObject();
            if (localIPropertySource2 != null)
            {
              TCComponent localTCComponent2 = SourceHelper.getAssociatedComponent(localIPropertySource2, localTCSession);
              if (localTCComponent2 != null)
              {
                TCComponentItemRevision localTCComponentItemRevision2 = (TCComponentItemRevision)AdapterUtil.getAdapter(localTCComponent2, TCComponentItemRevision.class);
                if ((localTCComponentItemRevision2 != null) && (MassUpdateHelper.isChangeItemRevision(localTCComponentItemRevision2))) {
                  bool = MassUpdateHelper.isProblemFolderAccessible(localTCComponentItemRevision2, localTCComponentItemRevision1);
                }
              }
            }
          }
        }
        else
        {
          localUpdateJobModel.setTargetPartImageDescriptor(null);
        }
        localUpdateJobModel.setProblemFolderAccessible(bool);
        if ((!bool) && (localUpdateJobModel.isSaveTargetPartInFolder())) {
          localUpdateJobModel.setSaveTargetPartInFolder(false);
        }
        localUpdateJobModel.setImpactedPartsUpToDate(false);
      }
    };
    getTCSession().queueOperation(local1);
  }
}
